package com.bcn.login_mybatis_demo.security;

public class SecurityUserHolder {

    private static final ThreadLocal<Long> userHolder = new ThreadLocal<>();

    // 设置当前用户的ID
    public static void setCurrentUserId(Long userId) {
        userHolder.set(userId);
    }

    // 获取当前用户的ID
    public static Long getCurrentUserId() {
        return userHolder.get();
    }

    // 清除当前用户的ID
    public static void clear() {
        userHolder.remove();
    }
}